using System.ComponentModel.DataAnnotations;
using StudentVideo.Shared.Constants;
using StudentVideo.Shared.Enums;

namespace StudentVideo.Shared.Dtos.Student;

/// <summary>
/// 学生创建数据传输对象
/// </summary>
public record class StudentCreateRequest: StudentBase {
   /// <summary>
   /// 学号
   /// </summary>
   [Required]
   [RegularExpression(Pattern.StudentIdPattern)]
   public required string Id { get; set; }

   /// <summary>
   /// 姓名
   /// </summary>
   [Required]
   [MaxLength(20, ErrorMessage = "Name cannot exceed 20 characters.")]
   public required string Name { get; set; }

   /// <summary>
   /// 身份证号码
   /// </summary>
   [Required]
   [RegularExpression(Pattern.IdCardPattern, ErrorMessage = "Invalid ID card number.")]
   [StringLength(18, MinimumLength = 15, ErrorMessage = "ID card number must be between 15 and 18 characters.")]
   public required string IdCard { get; set; }

   /// <summary>
   /// 联系电话
   /// </summary>
   [Required]
   [RegularExpression(Pattern.PhonePattern, ErrorMessage = "Invalid phone number.")]
   public required string Telephone { get; set; }

   /// <summary>
   /// 电子邮件
   /// </summary>
   public string? Email { get; set; }

   /// <summary>
   /// 性别
   /// </summary>
   public GenderEnum Gender { get; set; } = GenderEnum.Male;

   /// <inheritdoc />
   public new StudentGradeEnum SchoolYear { get; set; } = StudentGradeEnum.FirstYear;

   /// <summary>
   /// 学期
   /// </summary>
   public new StudentSemesterEnum Semester { get; set; } = StudentSemesterEnum.FirstSemester;

   /// <inheritdoc />
   [Required]
   public new required string Major { get; set; }

   /// <summary>
   /// 出生日期
   /// </summary>
   /// <example>1995-04-02</example>
   [RegularExpression(Pattern.FormatDatePattern, ErrorMessage = "Invalid birth date format.")]
   public string? Birth { get; set; }

   /// <summary>
   /// 入学日期
   /// </summary>
   /// <example>2023-03-15</example>
   [Required]
   [RegularExpression(Pattern.FormatDatePattern, ErrorMessage = "Invalid enrollment date format.")]
   public required string Enrollment { get; set; }

   /// <summary>
   /// 紧急联系人
   /// </summary>
   [Required]
   [MaxLength(15, ErrorMessage = "Emergency contact name cannot exceed 15 characters.")]
   public required string EmergencyContactName { get; set; }

   /// <summary>
   /// 紧急电话
   /// </summary>
   [Required]
   [RegularExpression(Pattern.PhonePattern, ErrorMessage = "Invalid emergency contact phone number.")]
   public required string EmergencyContactPhone { get; set; }

   /// <summary>
   /// 地址
   /// </summary>
   public string? Address { get; set; }
}
